package net.hn.hnms.biz.plan.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.hn.hnms.biz.plan.domain.DimMiningFace;
import net.hn.hnms.biz.plan.vo.DimMiningFaceVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface DimMiningFaceMapper extends BaseMapper<DimMiningFace> {

    @Select("<script>" +
            "  select " +
            " case when count(mining_face_id)>0 then count(mining_face_id)   else null end as totalDimMining," +
            " sum(mining_face_length) as totalMiningFaceLength, " +
            " sum(mining_face_thick) as totalMiningFaceThick, " +
            " max(estimate_end_date) as estimateEndDate " +
            " from dim_mining_face where del_flag='0' and mine_code= #{mineCode} " +
            "</script>")
    DimMiningFaceVO selectDimMiningFaceTotalByMineCode(@Param("mineCode") String mineCode);

    @Select("<script>" +
            "  select " +
            " case when count(mining_face_id)>0 then count(mining_face_id)   else null end as totalDimMining," +
            " sum(mining_face_length) as totalMiningFaceLength, " +
            " sum(mining_face_thick) as totalMiningFaceThick, " +
            " max(estimate_end_date) as estimateEndDate " +
            " from dim_mining_face where del_flag='0' and company_code= #{mineCode} " +
            "</script>")
    DimMiningFaceVO selectDrivageTotalByCompanyCodeOrName(@Param("mineCode") String mineCode);

    @Select("<script>" +
            "  select " +
            " mining_face_id ," +
            " mining_face_length , " +
            " mining_face_angle, " +
            " mining_face_high, " +
            " mining_face_name, " +
            " status, " +
            " mining_face_thick , " +
            " mine_code , " +
            " estimate_end_date as estimateEndDate, " +
            " relocation as relocation " +
            " from dim_mining_face where del_flag='0' and mine_code= #{mineCode} and status='0' " +
            "</script>")
    List<DimMiningFaceVO> selectDimMiningFaceByMineCode(@Param("mineCode") String mineCode);


    @Select("<script> select mining_face_id,mining_face_length from dim_mining_face where  mining_face_name=#{name} </script>")
    DimMiningFaceVO getWorkingFaceId(@Param("name") String name);

}
